package com.weita.lightfood.model.dao;


import com.weita.lightfood.model.entity.Dish;
import com.weita.lightfood.model.query.dish.AddDishQuery;
import com.weita.lightfood.model.vo.dish.DishCustomizedDishVo;
import com.weita.lightfood.model.vo.dish.MaterialNameAndWeight;
import com.weita.lightfood.model.vo.material.MateralNameNuvalueVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author IT_Monster at 2019/03/28 13:29.
 */
@Mapper
@Repository
public interface DishDao {
    /**
     * dish表中插入数据
     * @param addDishQuery
     * @throws Exception
     */
    void addDish(AddDishQuery addDishQuery) throws Exception;


    /**
     * 菜谱、标签中间表
     * @param cid
     * @param tid
     * @throws Exception
     */
    void dish__label(@Param("cid") int cid, @Param("tid") int tid) throws Exception;


    /**
     * 菜谱食材中间表
     * @param cid
     * @param sid
     * @param weight
     * @throws Exception
     */
    void dish__material(@Param("cid") int cid, @Param("sid") int sid, @Param("weight") int weight) throws Exception;

    /**
     * 设置食材展示状态
     * @param sid
     * @param headFlag
     * @throws Exception
     */
    void setHeadFlag(@Param("sid") int sid, @Param("headFlag") int headFlag) throws Exception;

    /**
     * 设置是否为精选食材
     * @param sid
     * @param choiceness
     * @param cid
     * @throws Exception
     */
    void setChoiceness(@Param("sid") int sid, @Param("choiceness") int choiceness, @Param("cid") int cid) throws Exception;

    /**
     * 通过菜品id获取其精选食材和介绍
     * @param dishId
     * @return
     * @throws Exception
     */
    List<MateralNameNuvalueVo> getMaterialByMenuId(int dishId) throws Exception;

    /**
     * 获取所有早餐0获取所有午餐1获取所有晚餐2
     * @param state
     * @return
     * @throws Exception
     */
    List<Dish> getDishes(int state) throws Exception;

    /**
     * 通过菜品id获取菜品食材name
     * @param dishId
     * @return
     * @throws Exception
     */
    List<String> getMaterialByDishId(int dishId) throws Exception;


    /**
     * 通过菜品id获取菜品主页展示食材
     * @param dishId
     * @return
     * @throws Exception
     */
    List<String> getHeadMaterialByDishId(int dishId) throws Exception;


    /**
     * 通过菜品id获取菜品标签
     * @param dishId
     * @return
     * @throws Exception
     */
    List<String> getLabelByDishId(int dishId) throws Exception;

    /**
     * 通过菜谱id获取菜谱
     * @param dishId
     * @return
     * @throws Exception
     */
    Dish getDishById(@Param("dishId") int dishId) throws Exception;


    /**
     * 通过菜谱id获取菜谱名
     * @param dishId
     * @return
     * @throws Exception
     */
    String getDishNameById(int dishId) throws Exception;

    /**
     * 通过食谱id获取定制用户饮食所需要的数据
     * @param dishId
     * @return
     * @throws Exception
     */
    DishCustomizedDishVo getDishCustomizedDishVo(int dishId) throws Exception;

    /**
     * 通过菜谱id获取其食材名和重量
     * @param dishId
     * @return
     * @throws Exception
     */
    List<MaterialNameAndWeight> getMaterial(int dishId) throws Exception;

    /**
     * 通过菜谱id获取精选食材名
     * @param dishId
     * @return
     * @throws Exception
     */
    List<String> getChoicenessMaterial(int dishId) throws Exception;

    /**
     * 保存图片地址
     * @param url
     * @param dishId
     * @throws Exception
     */
    void savePicPath(String url, int dishId) throws Exception;

    /**
     * 通过菜品id删除菜品
     * @param dishId
     * @throws Exception
     */
    void deleteDish(int dishId) throws Exception;

    /**
     * 获取所有模板
     * @return
     * @throws Exception
     */
    List<Dish> getAllTemplate() throws Exception;


    /**
     * 通过模板名搜索模板，可以使用dishService中的getAllTemplate方法处理
     * @param name
     * @return
     * @throws Exception
     */
    List<Dish> searchTemplate(String name) throws Exception;

    /**
     * 删除模板，将isTemplate字段标识为0
     * @param dishId
     * @throws Exception
     */
    void deleteTemplate(int dishId) throws Exception;


    /**
     * 根据菜谱id删除菜品标签，食材等相关信息
     * @param dishId
     * @throws Exception
     */
    void removeLabAndMate(int dishId) throws Exception;

    /**
     * 更新食材表
     * @param dish
     * @throws Exception
     */
    void updateDish(AddDishQuery dish) throws Exception;


    /**
     * 获取指定日期指定早中晚的配送中的订单数量
     * @param date
     * @param state
     * @return
     * @throws Exception
     */
    int getOrderCount(String date, int state) throws Exception;
}
